package com.ruoyi.config;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import org.camunda.bpm.engine.runtime.ProcessInstance;
import java.io.IOException;

public class ProcessInstanceSerializer extends JsonSerializer<ProcessInstance> {
    @Override
    public void serialize(ProcessInstance instance, JsonGenerator gen, SerializerProvider serializers) throws IOException {
        gen.writeStartObject();
        gen.writeStringField("id", instance.getId());
        gen.writeStringField("processDefinitionId", instance.getProcessDefinitionId());
        gen.writeStringField("businessKey", instance.getBusinessKey());
        gen.writeBooleanField("isEnded", instance.isEnded());
        gen.writeBooleanField("isSuspended", instance.isSuspended());
        // 添加其他需要的字段
        gen.writeEndObject();
    }
}